<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="业务单成本表" />
<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';NO_BUSI_COST;')==-1}">
	<c:set var="showCost" value="1" />
</c:if>
<%@ include file="../inc/Title.jsp"%>
<head>
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<link href="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/css/BillList.css" />
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script src="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<script language="javascript">
	function doShow(id){
		var url="/business/BusinessBillEdit.ihtm?id="+id;
		ShowIframe("业务单",url,1024,600,"refreshWin()",900,600);
	}
	function refreshWin(){
		if(popRetVal!=null){
			window.location.reload(true);
		}
	}
	function checkDateStr(){
		var startDate=document.getElementById("start_date").value;
		if(startDate==null || startDate==''){
			ShowAlert('提示框','请选择订货开始日期',200,100);
			return false;
		}else{
			var arr=startDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','订货开始日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','订货开始日期格式不正确',200,100);
				return false;
			}
		}
		var endDate=document.getElementById("end_date").value;
		if(endDate==null || endDate==''){
			ShowAlert('提示框','请选择订货结束日期',200,100);
			return false;
		}else{
			var arr=endDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','订货结束日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','订货结束日期格式不正确',200,100);
				return false;
			}
		}
		return true;
	}
	function checkClosDate(){
		var startDate=document.getElementById("clos_start").value;
		if(startDate==null || startDate==''){
			ShowAlert('提示框','请选择结清开始日期',200,100);
			return false;
		}else{
			var arr=startDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','结清开始日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','结清开始日期格式不正确',200,100);
				return false;
			}
		}
		var endDate=document.getElementById("clos_end").value;
		if(endDate==null || endDate==''){
			ShowAlert('提示框','请选择结清结束日期',200,100);
			return false;
		}else{
			var arr=endDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','结清结束日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','结清结束日期格式不正确',200,100);
				return false;
			}
		}
		return true;
	}
	function createPageParaStr(){
		var str="start_date="+encodeURIComponent(document.getElementById("start_date").value);
		str=str+"&end_date="+encodeURIComponent(document.getElementById("end_date").value);
		str=str+"&clos_start="+encodeURIComponent(document.getElementById("clos_start").value);
		str=str+"&clos_end="+encodeURIComponent(document.getElementById("clos_end").value);
		
		var comp="A";
		if(document.getElementById("comp1").checked){
			comp="Y";
		}else if(document.getElementById("comp2").checked){
			comp="N";
		}
		str=str+"&comp="+comp;
		
		var deli="A";
		if(document.getElementById("deli1").checked){
			deli="Y";
		}else if(document.getElementById("deli2").checked){
			deli="P";
		}else if(document.getElementById("deli3").checked){
			deli="N";
		}
		str=str+"&deli="+deli;
		
		var clos="A";
		if(document.getElementById("clos1").checked){
			clos="Y";
		}else if(document.getElementById("clos2").checked){
			clos="N";
		}
		str=str+"&clos="+clos;
		
		str=str+"&mng_id="+encodeURIComponent(document.getElementById("mng_id").value);
		str=str+"&mng_name="+encodeURIComponent(document.getElementById("mng_name").value);
		str=str+"&est_id="+encodeURIComponent(document.getElementById("est_id").value);
		str=str+"&est_name="+encodeURIComponent(document.getElementById("est_name").value);
		str=str+"&desi_id="+encodeURIComponent(document.getElementById("desi_id").value);
		str=str+"&desi_name="+encodeURIComponent(document.getElementById("desi_name").value);
		str=str+"&crea_id="+encodeURIComponent(document.getElementById("crea_id").value);
		str=str+"&crea_name="+encodeURIComponent(document.getElementById("crea_name").value);
		str=str+"&cont="+encodeURIComponent(document.getElementById("cont").value);
		str=str+"&bill_code="+encodeURIComponent(document.getElementById("bill_code").value);
		str=str+"&min_cont_cost="+encodeURIComponent(document.getElementById("min_cont_cost").value.trim());
		str=str+"&max_cont_cost="+encodeURIComponent(document.getElementById("max_cont_cost").value.trim());
		str=str+"&min_prof_cost="+encodeURIComponent(document.getElementById("min_prof_cost").value.trim());
		str=str+"&max_prof_cost="+encodeURIComponent(document.getElementById("max_prof_cost").value.trim());
		str=str+"&cont_code="+encodeURIComponent(document.getElementById("cont_code").value);
		str=str+"&ts_id="+document.getElementById("ts_id").value;
		str=str+"&intr_id="+encodeURIComponent(document.getElementById("intr_id").value);
		str=str+"&intr_name="+encodeURIComponent(document.getElementById("intr_name").value);
		str=str+"&foll_id="+encodeURIComponent(document.getElementById("foll_id").value);
		str=str+"&foll_name="+encodeURIComponent(document.getElementById("foll_name").value);
		str=str+"&department="+document.getElementById("department").value;
		str=str+"&order_by="+document.getElementById("order_by").value;
		str=str+"&order_sc="+document.getElementById("order_sc").value;
		return str;
	}
	
	function createProgramParaStr(){
		var str="start_date="+encodeURIComponent(document.getElementById("hid_start_date").value);
		str=str+"&end_date="+encodeURIComponent(document.getElementById("hid_end_date").value);
		str=str+"&clos_start="+encodeURIComponent(document.getElementById("hid_clos_start").value);
		str=str+"&clos_end="+encodeURIComponent(document.getElementById("hid_clos_end").value);
		str=str+"&comp=${comp}";
		str=str+"&deli=${deli}";
		str=str+"&clos=${clos}";
		str=str+"&mng_id=${mngId}";
		str=str+"&est_id=${estId}";
		str=str+"&desi_id=${desiId}";
		str=str+"&crea_id=${creaId}";
		str=str+"&intr_id=${intrId}";
		str=str+"&foll_id=${follId}";
		str=str+"&mng_name="+encodeURIComponent(document.getElementById("hid_mng_name").value);
		str=str+"&est_name="+encodeURIComponent(document.getElementById("hid_est_name").value);
		str=str+"&desi_name="+encodeURIComponent(document.getElementById("hid_desi_name").value);
		str=str+"&crea_name="+encodeURIComponent(document.getElementById("hid_crea_name").value);
		str=str+"&intr_name="+encodeURIComponent(document.getElementById("hid_intr_name").value);
		str=str+"&foll_name="+encodeURIComponent(document.getElementById("hid_foll_name").value);
		str=str+"&bill_code="+encodeURIComponent(document.getElementById("hid_bill_code").value);
		str=str+"&cont="+encodeURIComponent(document.getElementById("hid_cont").value);
		str=str+"&min_cont_cost="+encodeURIComponent(document.getElementById("hid_min_cont_cost").value);
		str=str+"&max_cont_cost="+encodeURIComponent(document.getElementById("hid_max_cont_cost").value);
		str=str+"&min_prof_cost="+encodeURIComponent(document.getElementById("hid_min_prof_cost").value);
		str=str+"&max_prof_cost="+encodeURIComponent(document.getElementById("hid_max_prof_cost").value);
		str=str+"&cont_code="+encodeURIComponent(document.getElementById("hid_cont_code").value);
		str=str+"&ts_id=${tsId}";
		str=str+"&department=${department}";
		str=str+"&order_by=${orderBy}";
		str=str+"&order_sc=${orderSc}";
		return str;
	}
	function doSearch(){
		var str;
		if(IsAdvSearch){//高级
			str="search_type=1";
			if(document.getElementById("cb_order_date").checked){
				if(checkDateStr()){
					str=str+"&cb_order_date=1";
				}else{
					return;
				}
			}
			if(document.getElementById("cb_clos_time").checked){
				if(checkClosDate()){
					str=str+"&cb_clos_time=1";
				}else{
					return;
				}
			}
			if(document.getElementById("cb_comp").checked){
				str=str+"&cb_comp=1";
			}
			if(document.getElementById("cb_deli").checked){
				str=str+"&cb_deli=1";
			}
			if(document.getElementById("cb_clos").checked){
				str=str+"&cb_clos=1";
			}
			if(document.getElementById("cb_intr").checked){
				var intrId=document.getElementById("intr_id").value;
				if(intrId==null || intrId=="" || intrId=="0"){
					ShowAlert('提示框','请选择业务来源',200,100);
					return;
				}
				str=str+"&cb_intr=1";
			}
			if(document.getElementById("cb_mng").checked){
				var mngId=document.getElementById("mng_id").value;
				if(mngId==null || mngId=="" || mngId=="0"){
					ShowAlert('提示框','请选择业务员',200,100);
					return;
				}
				str=str+"&cb_mng=1";
			}
			if(document.getElementById("cb_foll").checked){
				var follId=document.getElementById("foll_id").value;
				if(follId==null || follId=="" || follId=="0"){
					ShowAlert('提示框','请选择跟单员',200,100);
					return;
				}
				str=str+"&cb_foll=1";
			}
			if(document.getElementById("cb_desi").checked){
				var desiId=document.getElementById("desi_id").value;
				if(desiId==null || desiId=="" || desiId=="0"){
					ShowAlert('提示框','请选择设计员',200,100);
					return;
				}
				str=str+"&cb_desi=1";
			}
			if(document.getElementById("cb_crea").checked){
				var creaId=document.getElementById("crea_id").value;
				if(creaId==null || creaId=="" || creaId=="0"){
					ShowAlert('提示框','请选择开单人',200,100);
					return;
				}
				str=str+"&cb_crea=1";
			}
			if(document.getElementById("cb_est").checked){
				var estId=document.getElementById("est_id").value;
				if(estId==null || estId==""){
					ShowAlert('提示框','请选择客户',200,100);
					return;
				}
				str=str+"&cb_est=1";
			}
			if(document.getElementById("cb_bill_code").checked){
				var billCode=document.getElementById("bill_code").value.trim();
				if(billCode==null || billCode==""){
					ShowAlert('提示框','请输入业务单号',200,100);
					return;
				}
				str=str+"&cb_bill_code=1";
			}
			if(document.getElementById("cb_cont").checked){
				var cont=document.getElementById("cont").value.trim();
				if(cont==null || cont==""){
					ShowAlert('提示框','请输入摘要',200,100);
					return;
				}
				str=str+"&cb_cont=1";
			}
			if(document.getElementById("cb_cont_cost").checked){
				var minContCost=document.getElementById("min_cont_cost").value.trim();
				if(minContCost==null || minContCost==""){
					ShowAlert('提示框','请输入合同最小金额',200,100);
					return;
				}else if(isNaN(minContCost)){
					ShowAlert('提示框','合同最小金额只能是数字',200,100);
					return;
				}
				var maxContCost=document.getElementById("max_cont_cost").value.trim();
				if(maxContCost==null || maxContCost==""){
					ShowAlert('提示框','请输入合同最大金额',200,100);
					return;
				}else if(isNaN(maxContCost)){
					ShowAlert('提示框','合同最大金额只能是数字',200,100);
					return;
				}
				str=str+"&cb_cont_cost=1";
			}
			if(document.getElementById("cb_prof_cost").checked){
				var minProfCost=document.getElementById("min_prof_cost").value.trim();
				if(minProfCost==null || minProfCost==""){
					ShowAlert('提示框','请输入毛利最小金额',200,100);
					return;
				}else if(isNaN(minProfCost)){
					ShowAlert('提示框','毛利最小金额只能是数字',200,100);
					return;
				}
				var maxProfCost=document.getElementById("max_prof_cost").value.trim();
				if(maxProfCost==null || maxProfCost==""){
					ShowAlert('提示框','请输入毛利最大金额',200,100);
					return;
				}else if(isNaN(maxProfCost)){
					ShowAlert('提示框','毛利最大金额只能是数字',200,100);
					return;
				}
				str=str+"&cb_prof_cost=1";
			}
			if(document.getElementById("cb_cont_code").checked){
				var contCode=document.getElementById("cont_code").value.trim();
				if(contCode==null || contCode==""){
					ShowAlert('提示框','请输入合同号',200,100);
					return;
				}
				str=str+"&cb_cont_code=1";
			}
			if(document.getElementById("cb_dep").checked){
				var department=document.getElementById("department").value;
				if(department==null || department=="" || department=="0"){
					ShowAlert('提示框','请选择部门',200,100);
					return;
				}
				str=str+"&cb_dep=1";
			}
			if(document.getElementById("cb_ts").checked){
				var tsId=document.getElementById("ts_id").value;
				if(tsId==null || tsId=="" || tsId=="0"){
					ShowAlert('提示框','请选择帐套',200,100);
					return;
				}
				str=str+"&cb_ts=1";
			}
			if(document.getElementById("cb_order").checked){
				var orderBy=document.getElementById("order_by").value;
				if(orderBy==null || orderBy==""){
					ShowAlert('提示框','请选择排序类型',200,100);
					return;
				}
				str=str+"&cb_order=1";
			}
		}else{//快速
			str="search_type=2";
			if(!checkDateStr()){
				return;
			}
		}
		var paraStr=createPageParaStr();
		if(paraStr!=""){
			str=str+"&"+paraStr;
		}
		window.location="/business/BusinessProfitSearchResult.ihtm?"+str;
	}
	function doGo(pageIndex){
		var str=getSearchCondition();
		str=str+"&current_page="+pageIndex;
		window.location="/business/BusinessProfitSearchResult.ihtm?"+str;
	}
	function getSearchCondition(){
		var searchType="${searchType}";
		var str="search_type="+searchType;
		if(searchType=="1"){//高级
			<c:if test="${cbOrderDate=='1'}">str=str+"&cb_order_date=1";</c:if>
			<c:if test="${cbClosTime=='1'}">str=str+"&cb_clos_time=1";</c:if>
			<c:if test="${cbComp=='1'}">str=str+"&cb_comp=1";</c:if>
			<c:if test="${cbDeli=='1'}">str=str+"&cb_deli=1";</c:if>
			<c:if test="${cbClos=='1'}">str=str+"&cb_clos=1";</c:if>
			<c:if test="${cbIntr=='1'}">str=str+"&cb_intr=1";</c:if>
			<c:if test="${cbMng=='1'}">str=str+"&cb_mng=1";</c:if>
			<c:if test="${cbFoll=='1'}">str=str+"&cb_foll=1";</c:if>
			<c:if test="${cbDesi=='1'}">str=str+"&cb_desi=1";</c:if>
			<c:if test="${cbCrea=='1'}">str=str+"&cb_crea=1";</c:if>
			<c:if test="${cbEst=='1'}">str=str+"&cb_est=1";</c:if>
			<c:if test="${cbBillCode=='1'}">str=str+"&cb_bill_code=1";</c:if>
			<c:if test="${cbCont=='1'}">str=str+"&cb_cont=1";</c:if>
			<c:if test="${cbContCost=='1'}">str=str+"&cb_cont_cost=1";</c:if>
			<c:if test="${cbProfCost=='1'}">str=str+"&cb_prof_cost=1";</c:if>
			<c:if test="${cbContCode=='1'}">str=str+"&cb_cont_code=1";</c:if>
			<c:if test="${cbTs=='1'}">str=str+"&cb_ts=1";</c:if>
			<c:if test="${cbDep=='1'}">str=str+"&cb_dep=1";</c:if>
			<c:if test="${cbOrder=='1'}">str=str+"&cb_order=1";</c:if>
		}else{//快速
			
		}
		var paraStr=createProgramParaStr();
		if(paraStr!=""){
			str=str+"&"+paraStr;
		}
		return str;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function DoubleClick(it){
		var ob_arr = document.getElementsByName("query_checkbox");
		var id="";
		if(ob_arr.length>=it.getAttribute("index")){
			id=ob_arr[it.getAttribute("index")-1].value;
		}
		if(id==""){
			return;
		}
		doShow(id);
	}
	function doCancel(){
		window.close();
	}
	function doInit(){
		Window_Onload();
	}
	function checkInput(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function doCooperList(billId){
		document.getElementById("detailFrm").src="/cooper/CooperBillItemListForBusinessBill.ihtm?id="+billId;
	}
	function doAdjustList(billId){
		document.getElementById("detailFrm").src="/finance/AdjustBillItemListForBusinessBill.ihtm?examined=Y&id="+billId;
	}
	function doFeeList(bbId){
		document.getElementById("detailFrm").src="/finance/FeeBillListForBusinessBill.ihtm?bb_id="+bbId;
	}
	function doInOutList(billCode){
		document.getElementById("detailFrm").src="/storehouse/InOutItemListForBusinessBill.ihtm?show_cost=1&business_bill_code="+encodeURIComponent(billCode);
	}
	function showDetail(billId){
		showWin(1024,600,"/business/BusinessProfitDetail.ihtm?id="+billId);
	}
	
	function doAutoCheck(objId){
		document.getElementById(objId).checked=true;
	}
	function selectStafferName(idObjId,nameObjId,checkObjId){
		var url="/base/StafferMainForSelect.ihtm";
		ShowIframe("选择员工",url,800,500,"selectStafferNameCallBack('"+idObjId+"','"+nameObjId+"','"+checkObjId+"')");
	}
	function selectStafferNameCallBack(idObjId,nameObjId,checkObjId){
		if(popRetVal!=null){
			var arr=popRetVal.split(";");
			document.getElementById(idObjId).value=arr[0];
			document.getElementById(nameObjId).value=arr[1];
			doAutoCheck(checkObjId);
		}
	}
	function selectEstName(){
		var url="/base/EstablishmentListForSelect.ihtm?type=CLIENT";
		ShowIframe("选择客户",url,900,500,"selectEstNameCallBack()");
	}
	function selectEstNameCallBack(){
		if(popRetVal!=null){
			document.getElementById("est_id").value=popRetVal[0];
			document.getElementById("est_name").value=popRetVal[1];
			doAutoCheck("cb_est");
		}
	}
	function doDownload(){
		var str=getSearchCondition();
		window.location="/business/BusinessProfitSearchResult.ihtm?content_type=EXCEL&"+str;
	}
	function setDate(type){
		var d=new Date();
		var startStr="";
		var endStr="";
		if(type=="CURRENT_MONTH"){
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-01";
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="PREVIEW_MONTH"){
			d=new Date(d.getFullYear(),d.getMonth(),1);
			d.setDate(d.getDate()-1);
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-1";
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="TODAY"){
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="YESTERDAY"){
			d.setDate(d.getDate()-1);
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}
		document.getElementById("start_date").value=startStr;
		document.getElementById("end_date").value=endStr;
		doAutoCheck("cb_order_date");
	}
	function showRelBill(code){
		showWin(1024,600,"/business/BusinessRelBillList.ihtm?code="+encodeURIComponent(code));
	}
</script>
</head>
<body oncontextmenu="return false">
<div class="Wrap"><!-- 页面主框架 -->
    
	<div id="ListContainer" class="Container"><!-- 主体容器 -->
	    
	    <!-- 标题栏 -->
	    <div class="Heading BillIcon">
	        <div class="HeadingContent">
	            <h1>业务单成本表</h1>
	            <span class="Note">统计业务单的材料成本、外协成本、费用，计算出业务单的毛利</span>
	        </div>
	    </div>
	
		<!-- 主内容 -->
		<div class="Content">
	        <!-- 筛选控件栏 -->
	        <div class="FilterBar ClearFix">
	            <div class="SearchIcon"></div>
	            <span class="fl">
	            	<table class="MoreOption" cellpadding="0" cellspacing="0">
	            		<th class="c1" width="80px">
	            			<input type="checkbox" name="cb_order_date" id="cb_order_date" <c:if test="${cbOrderDate=='1' || searchType=='2'}">checked="true"</c:if> style="visibility:hidden;" />
	            			订货日期
	            		</th>
	            		<td width="360px">
	            			<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_order_date');" id="start_date" name="start_date" value="<c:out value="${startDate}" />">
			            	<img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('start_date'),'yyyy-mm-dd',this,false,'doAutoCheck(\'cb_order_date\')');">
			            	<input type="hidden" id="hid_start_date" value="<c:out value="${startDate}" />">
			            	至
			            	<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_order_date');" id="end_date" name="end_date" value="<c:out value="${endDate}" />">
			            	<img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('end_date'),'yyyy-mm-dd',this,false,'doAutoCheck(\'cb_order_date\')');">
			            	<input type="hidden" id="hid_end_date" value="<c:out value="${endDate}" />">
			            	<a href="javascript:setDate('CURRENT_MONTH');">本月</a>
							<a href="javascript:setDate('TODAY');">今天</a>
							<a href="javascript:setDate('YESTERDAY');">昨天</a>
							<a href="javascript:setDate('PREVIEW_MONTH');">上月</a>
	            		</td>
	            	</table>
	            </span>
				<span class="fr">
	            	<a href="javascript:;" id="lnkMoreOption">更多查询选项</a>
		  			<input type="button" value=" 查 询" onClick="doSearch();" class="buttom search-but" id="sSearchButton" name="sSearchButton">
		  			<input type="button" value=" 导 出" onClick="doDownload();" class="buttom search-out" id="sDownloadButton" name="sDownloadButton" <c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';NO_EXPO;')!=-1}">disabled="true"</c:if>>
	            </span>
				<div id="dvMoreOptionBox" class="MoreOptionBox" style="display:none;">
					<table class="MoreOption" cellpadding="0" cellspacing="0">
						<tr>
							<th class="c1" width="80px">
			        			<input type="checkbox" name="cb_clos_time" id="cb_clos_time" <c:if test="${cbClosTime=='1'}">checked="true"</c:if>>
			        			结清日期
			        		</th>
			    			<td width="260px">
			        			<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_clos_time');" id="clos_start" name="clos_start" value="<c:out value="${closStart}" />">
				            	<img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('clos_start'),'yyyy-mm-dd',this,false,'doAutoCheck(\'cb_clos_time\')');">
				            	<input type="hidden" id="hid_clos_start" value="<c:out value="${closStart}" />">
				            	至
				            	<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_clos_time');" id="clos_end" name="clos_end" value="<c:out value="${closEnd}" />">
				            	<img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('clos_end'),'yyyy-mm-dd',this,false,'doAutoCheck(\'cb_clos_time\')');">
				            	<input type="hidden" id="hid_clos_end" value="<c:out value="${closEnd}" />">
			    			</td>
			    			<th class="c2" width="80px">
			        			<input type="checkbox" name="cb_comp" id="cb_comp" <c:if test="${cbComp=='1'}">checked="true"</c:if>>
			        			完工状态
			        		</th>
			    			<td class="c2" width="280px">
			        			<input type="radio" name="comp" id="comp1" onClick="doAutoCheck('cb_comp');" <c:if test="${comp=='Y'}">checked="true"</c:if> >已完工
								<input type="radio" name="comp" id="comp2" onClick="doAutoCheck('cb_comp');" <c:if test="${comp=='N'}">checked="true"</c:if> >未完工
								<input type="radio" name="comp" id="comp3" onClick="doAutoCheck('cb_comp');" <c:if test="${comp==null || comp=='' || comp=='A'}">checked="true"</c:if> >全部
			    			</td>
			    		</tr>
			    		<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_est" id="cb_est" <c:if test="${cbEst=='1'}">checked="true"</c:if>>
			        			客户
			        		</th>
			    			<td class="c1">
			        			<input type="text" class="TextBox readonly" readonly="true" maxlength="15" name="est_name" id="est_name" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_est');" value="<c:out value="${estName}" />" >
								<img class="imgIconButton" src="/images/make-a.gif" onClick="selectEstName();" />
								<input type="hidden" id="est_id" value="<c:out value="${estId}" />">
								<input type="hidden" id="hid_est_name" value="<c:out value="${estName}" />">
			    			</td>
							<th class="c2">
			        			<input type="checkbox" name="cb_deli" id="cb_deli" <c:if test="${cbDeli=='1'}">checked="true"</c:if>>
			        			送货状态
			        		</th>
			    			<td class="c3">
			        			<input type="radio" name="deli" id="deli1" onClick="doAutoCheck('cb_deli');" <c:if test="${deli=='Y'}">checked="true"</c:if> >已送完
								<input type="radio" name="deli" id="deli2" onClick="doAutoCheck('cb_deli');" <c:if test="${deli=='P'}">checked="true"</c:if> >未送完
								<input type="radio" name="deli" id="deli3" onClick="doAutoCheck('cb_deli');" <c:if test="${deli=='N'}">checked="true"</c:if> >未送货
								<input type="radio" name="deli" id="deli4" onClick="doAutoCheck('cb_deli');" <c:if test="${deli==null || deli=='' || deli=='A'}">checked="true"</c:if> >全部
			    			</td>
						</tr>
						<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_cont_code" id="cb_cont_code" <c:if test="${cbContCode=='1'}">checked="true"</c:if>>
			        			合同号
			        		</th>
			        		<td class="c1">
			        			<input type="text" class="TextBox" maxlength="50" name="cont_code" id="cont_code" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cont_code');" value="<c:out value="${contCode}" />" >
								<input type="hidden" id="hid_cont_code" value="<c:out value="${contCode}" />">
			    			</td>
							<th class="c2">
			        			<input type="checkbox" name="cb_clos" id="cb_clos" <c:if test="${cbClos=='1'}">checked="true"</c:if>>
			        			结清状态
			        		</th>
			    			<td class="c3">
			        			<input type="radio" name="clos" id="clos1" onClick="doAutoCheck('cb_clos');" <c:if test="${clos=='Y'}">checked="true"</c:if> >已结清
								<input type="radio" name="clos" id="clos2" onClick="doAutoCheck('cb_clos');" <c:if test="${clos=='N'}">checked="true"</c:if> >未结清
								<input type="radio" name="clos" id="clos3" onClick="doAutoCheck('cb_clos');" <c:if test="${clos==null || clos=='' || clos=='A'}">checked="true"</c:if> >全部
			    			</td>
						</tr>
						<tr>
							<th class="c1">
			        			<input type="checkbox" name="cb_bill_code" id="cb_bill_code" <c:if test="${cbBillCode=='1'}">checked="true"</c:if>>
			        			业务单号
			        		</th>
			        		<td class="c1">
			        			<input type="text" class="TextBox" maxlength="50" name="bill_code" id="bill_code" onFocus="doAutoCheck('cb_bill_code');" onKeyUp="checkInput();" value="<c:out value="${billCode}" />">
								<input type="hidden" id="hid_bill_code" value="<c:out value="${billCode}" />">
			    			</td>
			    			<th class="c2">
			        			<input type="checkbox" name="cb_intr" id="cb_intr" <c:if test="${cbIntr=='1'}">checked="true"</c:if>>
			        			业务来源
			        		</th>
			    			<td class="c3">
			        			<input type="text" class="TextBox readonly" readonly="true" maxlength="15" name="intr_name" id="intr_name" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_intr');" value="<c:out value="${intrName}" />">
			        			<img class="imgIconButton" src="/images/make-a.gif" onClick="selectStafferName('intr_id','intr_name','cb_intr');" />
								<input type="hidden" id="hid_intr_name" value="<c:out value="${intrName}" />">
								<input type="hidden" id="intr_id" value="<c:out value="${intrId}" />">
			    			</td>
			    		</tr>
			    		<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_cont" id="cb_cont" <c:if test="${cbCont=='1'}">checked="true"</c:if>>
			        			摘要
			        		</th>
			        		<td class="c1">
			        			<input type="text" class="TextBox" maxlength="50" name="cont" id="cont" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cont');" value="${cont}" >
								<input type="hidden" id="hid_cont" value="<c:out value="${cont}" />">
			    			</td>
			    			<th class="c2">
			        			<input type="checkbox" name="cb_mng" id="cb_mng" <c:if test="${cbMng=='1'}">checked="true"</c:if>>
			        			业务员
			        		</th>
			    			<td class="c3">
			        			<input type="text" class="TextBox readonly" readonly="true" maxlength="15" name="mng_name" id="mng_name" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_mng');" value="<c:out value="${mngName}" />">
			        			<img class="imgIconButton" src="/images/make-a.gif" onClick="selectStafferName('mng_id','mng_name','cb_mng');" />
								<input type="hidden" id="hid_mng_name" value="<c:out value="${mngName}" />">
								<input type="hidden" id="mng_id" value="<c:out value="${mngId}" />">
			    			</td>
			    		</tr>
			    		<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_cont_cost" id="cb_cont_cost" <c:if test="${cbContCost=='1'}">checked="true"</c:if>>
			        			合同金额
			        		</th>
			    			<td>
			        			<input type="text" class="TextBox Money" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cont_cost');" id="min_cont_cost" name="min_cont_cost" value="<c:out value="${minContCost}" />" >
								至
								<input type="text" class="TextBox Money" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cont_cost');" id="max_cont_cost" name="max_cont_cost" value="<c:out value="${maxContCost}" />" >
								<input type="hidden" id="hid_min_cont_cost" value="<c:out value="${minContCost}" />">
								<input type="hidden" id="hid_max_cont_cost" value="<c:out value="${maxContCost}" />">
			    			</td>
							<th class="c2">
			        			<input type="checkbox" name="cb_foll" id="cb_foll" <c:if test="${cbFoll=='1'}">checked="true"</c:if>>
			        			跟单员
			        		</th>
			    			<td class="c3">
			        			<input type="text" class="TextBox readonly" readonly="true" maxlength="15" name="foll_name" id="foll_name" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_foll');" value="<c:out value="${follName}" />">
			        			<img class="imgIconButton" src="/images/make-a.gif" onClick="selectStafferName('foll_id','foll_name','cb_foll');" />
								<input type="hidden" id="hid_foll_name" value="<c:out value="${follName}" />">
								<input type="hidden" id="foll_id" value="<c:out value="${follId}" />">
			    			</td>
			    		</tr>
			    		<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_prof_cost" id="cb_prof_cost" <c:if test="${cbProfCost=='1'}">checked="true"</c:if>>
			        			毛利
			        		</th>
			    			<td>
			        			<input type="text" class="TextBox Money" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_prof_cost');" id="min_prof_cost" name="min_prof_cost" value="<c:out value="${minProfCost}" />" >
								至
								<input type="text" class="TextBox Money" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_prof_cost');" id="max_prof_cost" name="max_prof_cost" value="<c:out value="${maxProfCost}" />" >
								<input type="hidden" id="hid_min_prof_cost" value="<c:out value="${minProfCost}" />">
								<input type="hidden" id="hid_max_prof_cost" value="<c:out value="${maxProfCost}" />">
			    			</td>
			    			<th class="c2">
			        			<input type="checkbox" name="cb_desi" id="cb_desi" <c:if test="${cbDesi=='1'}">checked="true"</c:if>>
			        			设计员
			        		</th>
			    			<td class="c3">
			        			<input type="text" class="TextBox readonly" readonly="true" maxlength="15" name="desi_name" id="desi_name" readonly="true" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_desi');" value="<c:out value="${desiName}" />" >
								<img class="imgIconButton" src="/images/make-a.gif" onClick="selectStafferName('desi_id','desi_name','cb_desi');" />
								<input type="hidden" id="desi_id" value="<c:out value="${desiId}" />">
								<input type="hidden" id="hid_desi_name" value="<c:out value="${desiName}" />">
			    			</td>
	                	</tr>
	                	<tr>
	                		<th class="c1">
			        			<input type="checkbox" name="cb_dep" id="cb_dep" <c:if test="${cbDep=='1'}">checked="true"</c:if>>
			        			部门
			        		</th>
			    			<td class="c1">
			        			<select name="department" id="department" onFocus="doAutoCheck('cb_dep');">
	                            	<option value="0">==请选择==</option>
	                            	<commonTag:createSelectTree list="${departmentList}" emptyOption="0" defaultValue="${department}" />
	                        	</select>
	                        </td>
			    			<th class="c2">
			        			<input type="checkbox" name="cb_crea" id="cb_crea" <c:if test="${cbCrea=='1'}">checked="true"</c:if>>
			        			开单人
			        		</th>
			    			<td class="c3">
			        			<input type="text" class="TextBox readonly" readonly="true" maxlength="15" name="crea_name" id="crea_name" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_crea');" value="<c:out value="${creaName}" />">
								<img class="imgIconButton" src="/images/make-a.gif" onClick="selectStafferName('crea_id','crea_name','cb_crea');" />
								<input type="hidden" id="hid_crea_name" value="<c:out value="${creaName}" />">
								<input type="hidden" id="crea_id" value="<c:out value="${creaId}" />">
			    			</td>
	                	</tr>
	                	<tr>
	                		<th class="c1">
			    				<input type="checkbox" name="cb_ts" id="cb_ts" <c:if test="${cbTs=='1'}">checked="true"</c:if>>
	                        	账套
			    			</th>
			    			<td class="c1">
			    				<select name="ts_id" id="ts_id" onFocus="doAutoCheck('cb_ts');">
				    				<option value="0">==请选择账套==</option>
				    				<c:forEach var="item" items="${tsList}">
									<option value="${item.id}" <c:if test="${tsId==item.id}">selected</c:if>>${item.title}</option></c:forEach>
								</select>
			    			</td>
			    			<th class="c2">&nbsp;</th>
			    			<td class="c3">&nbsp;</td>
	                	</tr>
					</table>
					<div class="OptionOrderBy">
	                	<input type="checkbox" name="cb_order" id="cb_order" <c:if test="${cbOrder=='1'}">checked="true"</c:if>>
	                    	排序类型
	                    <select name="order_by" id="order_by" onFocus="doAutoCheck('cb_order');">
	                        <option value="">==请选择==</option>
	                        <option value="ORDER_DATE" <c:if test="${orderBy=='ORDER_DATE'}">selected</c:if>>订货日期</option>
	                        <option value="BILL_CODE" <c:if test="${orderBy=='BILL_CODE'}">selected</c:if>>单号</option>
	                    </select>
	                    <select name="order_sc" id="order_sc" onFocus="doAutoCheck('cb_order');">
	                        <option value="ASC" <c:if test="${orderSc=='ASC'}">selected</c:if>>升序</option>
	                        <option value="DESC" <c:if test="${orderSc=='DESC'}">selected</c:if>>降序</option>
	                    </select>
	                    <span class="fr"><a href="javascript:;" id="lnkHiddenOption">隐藏查询选项</a></span>
	                </div>
				</div>
			</div>
			
			<!-- 提示信息显示栏 -->
	        <div class="MsgBar">
	            <%@include file="../inc/AlertMsg.jsp"%>
	        </div>

			<!-- 上栏 分页、操作等 -->
			<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';NO_TOTA;')==-1}">
	        <div class="TopToolBar">
	            <table class="ListNoteInfo" cellpadding="0" cellspacing="0">
	            	<tr>
	                	<td>
            				<span>毛利小计：${profitCost}元</span>
            				<span>毛利率：${profitPercent}%</span>
	                	</td>
	            	</tr>
	            </table>
			</div>
			</c:if>

      		<div class="table-list">
		        <table width="100%">
		          	<tr>
						<th width="10%" rowSpan="2">客户</td>
						<th width="8%" rowSpan="2">订货日期</td>
						<th width="10%" rowSpan="2">单号</td>
						<th width="14%" rowSpan="2">摘要</td>
						<th width="14%" colSpan="2">收入</td>
						<th width="18%" colSpan="3">成本</td>
						<th width="7%" rowSpan="2">毛利</td>
						<th width="5%" rowSpan="2">毛利率</td>
						<th width="7%" rowSpan="2">已收金额</td>
						<th width="7%" rowSpan="2">尚欠金额</td>
		          	</tr>
				  	<tr>
						<th width="7%">合同金额</td>
						<th width="7%">已调账</td>
						<th width="6%">材料</td>
						<th width="6%">外协</td>
						<th width="6%">费用</td>
		          	</tr>
					<c:forEach var="item" items="${qr.list}" varStatus="i">
					<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
					<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
					<tr class="${trClass}" style="color:#000000" defaultFontColor="#000000" index="${i.index+1}" style='cursor:pointer;' ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
						<td>${item[8]}</td>
						<td><fmt:formatDate value="${item[2]}" pattern="yyyy-MM-dd"/></td>
						<td >
							<input type="radio" onClick="javascript:ClickCheck(this);" name='query_checkbox' value="${item[0]}" style="display:none">
							<a href="javascript:showRelBill('${item[1]}');">${item[1]}</a>
						</td>
						<td>${item[15]}</td>
						<td align="right"><commonTag:parseBigDecimal source="${item[3]}" /></td>
						<td align="right"><commonTag:parseBigDecimal source="${item[5]}" /></td>
						<td align="right"><commonTag:parseBigDecimal source="${item[9]}" /></td>
						<td align="right"><commonTag:parseBigDecimal source="${item[10]}" /></td>
						<td align="right"><commonTag:parseBigDecimal source="${item[11]}" /></td>
						<td align="right"><a href="javascript:showDetail(${item[0]});"><commonTag:parseBigDecimal source="${item[12]}" /></a></td>
						<td align="right">${item[20]}%</td>
						<td align="right"><commonTag:parseBigDecimal source="${item[4]}" /></td>
						<td align="right"><commonTag:parseBigDecimal source="${item[3]-item[4]+item[5]}" /></td>
					</tr>
					</c:forEach>   
				</table> 
			</div>
      		<!-- 底栏 分页、操作等 -->
	        <div class="BottomToolBar ClearFix">
			    <%@include file="../inc/Pages.jsp"%>
	        </div>
			
		</div>
	</div>
	
	<table width="100%"  border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td align="center" height="0">
				<iframe name="detailFrm" id="detailFrm" scrolling="no" border="0" frameborder="0" height="0" width="100%" src=""></iframe>
			</td>
		</tr>
	</table>
	
</div>
</body>
</html>
<script type="text/javascript">
	function ChangeWindowSize( container, maxWidth ){
	    setTimeout( function(){
	        var w1 = document.documentElement.clientWidth-40;
	        if( w1>maxWidth ) w1 = maxWidth;
	        else if( w1<870 ) w1 = 860;
	        container.style.width = w1+'px';
	    }, 300 );
	}
	var IsAdvSearch = false;
	(function(){
		doInit();
	    var ListContainer = document.getElementById('ListContainer');
	    ChangeWindowSize( ListContainer, 2020 );    // 超过 1280 的最大 1260 ，不全部铺满
	
	    var lnkMoreOption   = document.getElementById('lnkMoreOption');
	    var lnkHiddenOption = document.getElementById('lnkHiddenOption');
	    lnkMoreOption.onclick = function(){
	    	IsAdvSearch = true;
	        document.getElementById('dvMoreOptionBox').style.display = 'block';
	        document.getElementById('cb_order_date').style.visibility = 'visible';
	        this.style.visibility = 'hidden';
	    };
	    lnkHiddenOption.onclick = function(){
	    	IsAdvSearch = false;
	        document.getElementById('dvMoreOptionBox').style.display = 'none';
	        document.getElementById('cb_order_date').style.visibility = 'hidden';
	        lnkMoreOption.style.visibility = 'visible';
	    };
	})();
</script>
